\hypertarget{group__balancer}{}\section{负载均衡器}
\label{group__balancer}\index{负载均衡器@{负载均衡器}}
\subsection*{函数}
\begin{DoxyCompactItemize}
\item 
\hyperlink{struct__loop__balancer__t}{loop\+\_\+balancer\+\_\+t} $\ast$ \hyperlink{group__balancer_ga9992a50e96839282c678e51bc11158d1}{loop\+\_\+balancer\+\_\+create} ()
\item 
void \hyperlink{group__balancer_ga2d702b5f965fe587fdaea3f5f9e2400c}{loop\+\_\+balancer\+\_\+destroy} (\hyperlink{struct__loop__balancer__t}{loop\+\_\+balancer\+\_\+t} $\ast$balancer)
\item 
int \hyperlink{group__balancer_ga2b3cf2cb63d914efe226e901a50d8b0a}{loop\+\_\+balancer\+\_\+attach} (\hyperlink{struct__loop__balancer__t}{loop\+\_\+balancer\+\_\+t} $\ast$balancer, \hyperlink{struct__loop__t}{loop\+\_\+t} $\ast$loop)
\item 
int \hyperlink{group__balancer_ga548ce0c2c624c4f4731a0f963d2ca42a}{loop\+\_\+balancer\+\_\+detach} (\hyperlink{struct__loop__balancer__t}{loop\+\_\+balancer\+\_\+t} $\ast$balancer, \hyperlink{struct__loop__t}{loop\+\_\+t} $\ast$loop)
\end{DoxyCompactItemize}


\subsection{详细描述}

\begin{DoxyPre}
负载均衡器可以与任意数量的loop\_t关联，关联后的loop\_t内监听器接受到的新管道
将参与负载均衡，负载均衡的策略是loop\_t内活跃管道数量，loop\_balancer\_t选择
活跃管道最少的loop\_t负载新接受的管道.
调用loop\_balancer\_attach让loop\_balancer\_t与loop\_t关联，调用loop\_balancer\_detach
取消关联.
\end{DoxyPre}
 

\subsection{函数说明}
\hypertarget{group__balancer_ga2b3cf2cb63d914efe226e901a50d8b0a}{}\index{负载均衡器@{负载均衡器}!loop\+\_\+balancer\+\_\+attach@{loop\+\_\+balancer\+\_\+attach}}
\index{loop\+\_\+balancer\+\_\+attach@{loop\+\_\+balancer\+\_\+attach}!负载均衡器@{负载均衡器}}
\subsubsection[{loop\+\_\+balancer\+\_\+attach}]{\setlength{\rightskip}{0pt plus 5cm}int loop\+\_\+balancer\+\_\+attach (
\begin{DoxyParamCaption}
\item[{{\bf loop\+\_\+balancer\+\_\+t} $\ast$}]{balancer, }
\item[{{\bf loop\+\_\+t} $\ast$}]{loop}
\end{DoxyParamCaption}
)}\label{group__balancer_ga2b3cf2cb63d914efe226e901a50d8b0a}
添加事件循环到负载均衡器 
\begin{DoxyParams}{参数}
{\em balancer} & loop\+\_\+balancer\+\_\+t实例 \\
\hline
{\em loop} & loop\+\_\+t实例 \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{返回值}
{\em error\+\_\+ok} & 成功 \\
\hline
{\em 其他} & 失败 \\
\hline
\end{DoxyRetVals}
\hypertarget{group__balancer_ga9992a50e96839282c678e51bc11158d1}{}\index{负载均衡器@{负载均衡器}!loop\+\_\+balancer\+\_\+create@{loop\+\_\+balancer\+\_\+create}}
\index{loop\+\_\+balancer\+\_\+create@{loop\+\_\+balancer\+\_\+create}!负载均衡器@{负载均衡器}}
\subsubsection[{loop\+\_\+balancer\+\_\+create}]{\setlength{\rightskip}{0pt plus 5cm}{\bf loop\+\_\+balancer\+\_\+t}$\ast$ loop\+\_\+balancer\+\_\+create (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}\label{group__balancer_ga9992a50e96839282c678e51bc11158d1}
创建负载均衡器 \begin{DoxyReturn}{返回}
loop\+\_\+balancer\+\_\+t实例 
\end{DoxyReturn}
\hypertarget{group__balancer_ga2d702b5f965fe587fdaea3f5f9e2400c}{}\index{负载均衡器@{负载均衡器}!loop\+\_\+balancer\+\_\+destroy@{loop\+\_\+balancer\+\_\+destroy}}
\index{loop\+\_\+balancer\+\_\+destroy@{loop\+\_\+balancer\+\_\+destroy}!负载均衡器@{负载均衡器}}
\subsubsection[{loop\+\_\+balancer\+\_\+destroy}]{\setlength{\rightskip}{0pt plus 5cm}void loop\+\_\+balancer\+\_\+destroy (
\begin{DoxyParamCaption}
\item[{{\bf loop\+\_\+balancer\+\_\+t} $\ast$}]{balancer}
\end{DoxyParamCaption}
)}\label{group__balancer_ga2d702b5f965fe587fdaea3f5f9e2400c}
销毁负载均衡器 
\begin{DoxyParams}{参数}
{\em balancer} & loop\+\_\+balancer\+\_\+t实例 \\
\hline
\end{DoxyParams}
\hypertarget{group__balancer_ga548ce0c2c624c4f4731a0f963d2ca42a}{}\index{负载均衡器@{负载均衡器}!loop\+\_\+balancer\+\_\+detach@{loop\+\_\+balancer\+\_\+detach}}
\index{loop\+\_\+balancer\+\_\+detach@{loop\+\_\+balancer\+\_\+detach}!负载均衡器@{负载均衡器}}
\subsubsection[{loop\+\_\+balancer\+\_\+detach}]{\setlength{\rightskip}{0pt plus 5cm}int loop\+\_\+balancer\+\_\+detach (
\begin{DoxyParamCaption}
\item[{{\bf loop\+\_\+balancer\+\_\+t} $\ast$}]{balancer, }
\item[{{\bf loop\+\_\+t} $\ast$}]{loop}
\end{DoxyParamCaption}
)}\label{group__balancer_ga548ce0c2c624c4f4731a0f963d2ca42a}
从负载均衡器内删除事件循环 
\begin{DoxyParams}{参数}
{\em balancer} & loop\+\_\+balancer\+\_\+t实例 \\
\hline
{\em loop} & loop\+\_\+t实例 \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{返回值}
{\em error\+\_\+ok} & 成功 \\
\hline
{\em 其他} & 失败 \\
\hline
\end{DoxyRetVals}
